<?php
if (!defined('RAPIDLEECH')){
  require_once("../404.php");exit;
}

$checker = array();  


function retchk($flag, $msg=''){
   if(!isset($flag)) return;
   return 
    '<span class="'.($flag==1 ? 'okay' : 'fail').'">' .
	 ($flag==1 ? 'Passed' : ($msg!='' ? $msg : 'Failed') ) .
	'</span>';
}

$apacver = phpversion();
$checker["phpver"] = str_replace(".", "", $apacver);
$checker["phpver"] = ($checker["phpver"] >= 430 ? retchk(1) : retchk(0));

$checker["safemode"]        = (ini_get('safe_mode') ? retchk(0) : retchk(1));
$checker["fsockopen"]       = (!function_exists('fsockopen') ? retchk(0) : retchk(1));
$checker["memory_limit"]    = ((int)ini_get('memory_limit') > 32 ? retchk(1) : retchk(0));
$checker["curl"]            = (!function_exists('curl_version') ? retchk(0) : retchk(1));
$checker["fopen"]           = (!ini_get('allow_url_fopen') ? retchk(0) : retchk(1));
$checker["call_time"]       = (!ini_get('allow_call_time_pass_reference') ? retchk(0, 'You might see warnings without this turned on') : retchk(1));
$checker["passthru"]        = (!function_exists('passthru') ? retchk(0, 'You might not be able to turn on server stats') : retchk(1));
$checker["disk_free_space"] = (!function_exists('disk_free_space') ? retchk(0, 'You might not be able to turn on server stats') : retchk(1));

if (function_exists('apache_get_version')) {
	$apache_version = apache_get_version();
	preg_match('/Apache\/([0-9])\./U',$apache_version,$match);	
	$checker["apacver"] = ($match[1] < 2 ? retchk(0, 'Your server might not be able to support files more than 2 GB' ) : retchk(1) );
}


?><table border="0" width="90%" cellpadding="0" align="center">
   <tr>
    <td>
	<form action="" method="get">
      <table border="0" cellpadding="0" cellspacing="0">
        <tr>
         <td align="center">
          <div class="chk_content">
      	   <b>Rapidleech pre-Setup Check</b>
      	  </div>
         </td>
        </tr>
        <tr>
          <td align="left" class="chk_content">
          <ol>
            <li><b>fsockopen</b>: <?php echo $checker["fsockopen"]; ?></li>
            <li><b>memory_limit</b>: <?php echo $checker["memory_limit"]; ?></li>
            <li><b>safe_mode</b>: <?php echo $checker["safemode"]; ?></li>
            <li><b>cURL</b>: <?php echo $checker["curl"]; ?></li>
            <li><b>allow_url_fopen</b>: <?php echo $checker["fopen"]; ?></li>
            <li><b>PHP Version - <?php echo $apacver; ?></b>: <?php echo $checker["phpver"]; ?></li>
            <li><b>allow_call_time_pass_reference</b>: <?php echo $checker["call_time"]; ?></li>
            <li><b>passthru</b>: <?php echo $checker["passthru"]; ?></li>
            <li><b>Disk Space Functions</b>: <?php echo $checker["disk_free_space"]; ?></li>
      	  
            <?php if ($apache_version) { ?><li><b>Apache Version - <?php echo $apache_version; ?></b>: <?php echo $checker["apacver"]; ?></li><?php }?>
          </ol>
          </td>
        </tr>			   
      </table>
      <input type="hidden" name="refresh" value="1" />
      <input type="submit" value="Refresh" class="button"/>
    </form>
    </td>
   </tr>
</table>